<?php

/**
 * This is the model class for table "member".
 *
 * The followings are the available columns in table 'member':
 * @property string $mem_username
 * @property string $mem_password
 * @property string $mem_cnname
 * @property integer $mem_age
 * @property integer $mem_tel
 * @property string $mem_createtime
 * @property string $mem_state
 * @property string $mem_statetime
 */
class Member extends EActiveRecord
{
	// public function save()
	// {
		// $this->mem_statetime = $_SERVER['REQUEST_TIME'];
		// parent::save();
	// }
	
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{member}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('mem_age, mem_tel', 'numerical', 'integerOnly'=>true),
			array('mem_username', 'length', 'max'=>40),
			array('mem_password', 'length', 'max'=>64),
			array('mem_cnname', 'length', 'max'=>100),
			array('mem_createtime, mem_statetime', 'length', 'max'=>10),
			array('mem_state', 'length', 'max'=>50),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('mem_username, mem_password, mem_cnname, mem_age, mem_tel, mem_createtime, mem_state, mem_statetime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'mem_username' => 'Mem Username',
			'mem_password' => 'Mem Password',
			'mem_cnname' => 'Mem Cnname',
			'mem_age' => 'Mem Age',
			'mem_tel' => 'Mem Tel',
			'mem_createtime' => 'Mem Createtime',
			'mem_state' => 'Mem State',
			'mem_statetime' => 'Mem Statetime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('mem_username',$this->mem_username,true);
		$criteria->compare('mem_password',$this->mem_password,true);
		$criteria->compare('mem_cnname',$this->mem_cnname,true);
		$criteria->compare('mem_age',$this->mem_age);
		$criteria->compare('mem_tel',$this->mem_tel);
		$criteria->compare('mem_createtime',$this->mem_createtime,true);
		$criteria->compare('mem_state',$this->mem_state,true);
		$criteria->compare('mem_statetime',$this->mem_statetime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Member the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
